<template>
  <div class="search-result">
    <van-list>
      <van-cell
        v-for="(article, index) in list"
        :key="index"
        @click="
          $router.push({
            name: 'article',
            params: {
              articleId: article._id
            }
          })
        "
        :title="article.title"
      />
    </van-list>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    searchText: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      list: []
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {
    this.onLoad()
  },
  methods: {
    onLoad () {
      this.$http('api/tableTest/page', {
        params: {
          page: 1,
          limit: 30,
          name: this.searchText,
          field: 'title'
        }
      }).then(({ data: res }) => {
        this.list = res.data
      })
    }
  }
}
</script>

<style scoped lang="less">
.search-result {
  position: fixed;
  left: 0;
  right: 0;
  top: 54px;
  bottom: 50px;
  overflow-y: auto;
}
</style>
